package com.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mapper.auto.SchoolMapper;
import com.model.auto.School;
import com.service.ISchoolService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author astupidcoder
 * @since 2022-09-14
 */
@Service
public class SchoolServiceImpl extends ServiceImpl<SchoolMapper, School> implements ISchoolService {

    @Override
    public School selectOneByParams(String schoolCode, Integer majorType, String batch, String recruitType) {
        List<School> schools=this.list(new LambdaQueryWrapper<School>()
                .eq(School::getCode, schoolCode)
                .eq(School::getBatch,batch)
                .eq(School::getType,majorType)
                .eq(StringUtils.hasText(recruitType), School::getRecruitType, recruitType)
        );
        if(Objects.nonNull(schools) && schools.size()>0){
            return schools.get(0);
        }
        return null;
    }
}
